<?php
include ('shuju.php');
session_start();
$sql='SELECT * FROM msg ORDER BY id DESC ';
$mysqli_result=$link->query($sql);
//$is=$mysqli_result->fetch_array();
//var_dump($is);
$rows=array();
while ($is=$mysqli_result->fetch_array(MYSQLI_ASSOC)){
    $rows[]=$is;
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        .add{
            width: 600px;
            margin: 0 auto;
        }
        .area{
            width: 100%;
            height: 100px;
            margin-bottom: 10px;
        }
        .btn{
            float: right;
        }
        .msg{
            margin: 30px 0 0 0;
        }
        .item{
            margin: 0 0 20px 0;
            border: 1px solid #ccc;
        }
        .about{
            color: #999;
        }
        p{
            margin-top: 10px;
        }
        .time{
            float: right;
            color: #999;
        }
    </style>
</head>
<body>
<div class="add">
    <form action="http://127.0.0.1:8080/php/ziji/1/index.php" method="post">

        <textarea name="mazmun" class="area"></textarea>

        <input name="user" class="text" type="text" />

        <input class="btn" type="submit" value="发布" />
        <a style="float: right" href="login.php">登记</a>
    </form>
    <div class="msg">
        <?php
        foreach ($rows as $is) {
            $time=date('y-m-d H:i:s',$is['time']);
            ?>
            <div class="item">
                <span class="about"><?php echo $is['username']?></span>
                <span class="time"><?php echo $time ?>
                <?php
                    if(isset($_SESSION['user'])) {
                 ?>
                     <a onclick="return confirm('你确定删除吗?')" href="delete.php?id=<?php echo $is['id'] ?>">删除</a>
                 <?php
                    }
                 ?>
                </span>
                <p><?php echo $is['contact']?></p>
            </div>
        <?php
        }
        ?>
    </div>
</div>
</body>
</html>